﻿using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using System.Data;
using ModuleDALCore;

namespace DAL
{
	public class CHITIETLABODAO : DALBase
	{
		public CHITIETLABODAO()
		{
			this.OpenConnect();
		}
		private DataTable dt;
		private string _SpName;

		public string SpName
		{
			get { return "SPCHITIETLABO"; }
			set { _SpName = value; }
		}
		public List<CHITIETLABO> GetListCTLBs()
		{
			List<CHITIETLABO> ctr = new List<CHITIETLABO>();
			dt = new DataTable();

			try
			{
				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(new CHITIETLABO(), null), ConvertClassToArray.GetValues(new CHITIETLABO(), 0));
				ctr = (List<CHITIETLABO>) ConvertDatatableToList.ConvertTo<CHITIETLABO>(dt);
			}

                        catch { return null; }

			return ctr;
		}
		public List<CHITIETLABO> FindwIDSOKB(CHITIETLABO bm)
		{
			dt = new DataTable();
			List<CHITIETLABO> lb = new List<CHITIETLABO>();
			try
			{
				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(bm, null), ConvertClassToArray.GetValues(bm, 0));
				lb = (List<CHITIETLABO>) ConvertDatatableToList.ConvertTo<CHITIETLABO>(dt);
			}
			catch { return null; }
			return lb;
		}

		public DataTable GetListCTLB()
		{
			dt = new DataTable();
			try
			{

				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(new CHITIETLABO(), null), ConvertClassToArray.GetValues(new CHITIETLABO(), 0));
				return dt;
			}
			catch { return null; }
		}
		public DataTable GetPHIEULABORPT(CHITIETLABO bm)
		{
			dt = new DataTable();
			try
			{
				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(bm, null), ConvertClassToArray.GetValues(bm, 6));
			}
			catch { return null; }
			return dt;
		}
		public String CreatenewId()
		{
			try
			{
				return "CTR" + DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(new CHITIETLABO(), null), ConvertClassToArray.GetValues(new CHITIETLABO(), 1));

			}
			catch { return null; }
		}
		public List<CHITIETLABO> GetCTLBbyIDBN(CHITIETLABO bm)
		{
			dt = new DataTable();
			List<CHITIETLABO> lb = new List<CHITIETLABO>();
			try
			{
				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(bm, null), ConvertClassToArray.GetValues(bm, 4));
				lb = (List<CHITIETLABO>)ConvertDatatableToList.ConvertTo<CHITIETLABO>(dt);
			}
			catch { return null; }
			return lb;
		}
		public bool INSERT(CHITIETLABO ctr)
		{
			try
			{
				return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(ctr, null), ConvertClassToArray.GetValues(ctr, 1)) == 1);

			}
			catch { return false; }
		}
		public bool UPDATE(CHITIETLABO ctr)
		{
			try
			{
				return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(ctr, null), ConvertClassToArray.GetValues(ctr, 2)) == 1);

			}
			catch { return false; }
		}
		public bool DELETE(CHITIETLABO ctr)
		{
			try
			{
				return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(ctr, null), ConvertClassToArray.GetValues(ctr, 3)) == 1);

			}
			catch { return false; }
		}
		public List<CHITIETLABO> FindTheoNCC(CHITIETLABO bm)
		{
			dt = new DataTable();
			List<CHITIETLABO> lb = new List<CHITIETLABO>();
			try
			{
				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(bm, null), ConvertClassToArray.GetValues(bm, 7));
				lb = (List<CHITIETLABO>)ConvertDatatableToList.ConvertTo<CHITIETLABO>(dt);
			}
			catch { return null; }
			return lb;
		}
		public DataTable FindTheoNCCDate(CHITIETLABO bm)
		{
			dt = new DataTable();
			try
			{
				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(bm, null), ConvertClassToArray.GetValues(bm, 8));
			}
			catch { return null; }
			return dt;
		}
	}
}